package com.ylbh.modules.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ylbh.common.pojo.business.dto.BusinessDetailsDTO;
import com.ylbh.common.pojo.business.dto.BusinessPicDTO;
import com.ylbh.common.pojo.business.dto.NoAdoptDTO;
import com.ylbh.common.pojo.business.dto.ToExamineDTO;
import com.ylbh.common.pojo.business.vo.GetUserInfoVO;
import com.ylbh.common.pojo.business.vo.ToExamineDetailsVO;
import com.ylbh.common.pojo.business.vo.ToExamineListVO;
import com.ylbh.common.pojo.finance.dto.*;
import com.ylbh.common.pojo.finance.vo.FinanceDetailsVO;
import com.ylbh.common.pojo.finance.vo.FinanceListVO;
import com.ylbh.modules.balancelog.entity.ShoppingBalanceLog;
import com.ylbh.modules.business.entity.ShoppingUserRevenueLog;
import com.ylbh.modules.business.entity.ShoppingUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 *
 *
 * @author czx
 * @date 2019-04-15 15:35:45
 */
@Mapper
@Repository
public interface ShoppingUserMapper extends BaseMapper<ShoppingUser> {

    /**
     * 查看联盟店审核列表
     * @param toExamineListDTO
     * @param page
     * @return
     */
    List<ToExamineListVO> selectBusinessList(ToExamineDTO toExamineListDTO, Page page);

    /**
     * 联盟店未审核数量
     * @return
     */
    int selectCount();

    /**
     * 允许联盟店通过审核
     * @param id
     */
    void updateStatusById(Long id);

    /**
     * 不允许联盟店通过审核
     * @param noAdopt
     */
    void updateStatusByIds(@Param(value = "noAdopt") NoAdoptDTO noAdopt);

    /**
     * 批量删除
     * @param list
     */
    void deleteBatchIds(@Param(value = "list") List<String> list);

    /**
     * 根据id查询联盟店的详情
     * @param id
     * @return
     */
    ToExamineDetailsVO selectBusinessUserById(Long id);

    /**
     * 运营打款列表
     * @param financeListDTO
     * @param page
     * @return
     */
    List<FinanceListVO> selectFinanceList(@Param(value = "financeListDTO") FinanceListDTO financeListDTO,Page page);

    /**
     * 运营打款详情
     * @param id
     * @return
     */
    FinanceDetailsVO selectFinanceById(@Param(value = "id")Long id);

    /**
     * 修改商家详情
     * @param financeDetailsVO
     */
    void updateFinanceById(@Param(value = "financeDetailsDTO") FinanceDetailsDTO financeDetailsDTO);

    /**
     * 修改用户的余额
     * @param commissionMoney
     * @param yesExtract
     * @param id
     */
    void updateBalanceById(BigDecimal commissionMoney, BigDecimal yesExtract, Long id);

    /**
     * 新增提现日志
     * @param withdrawalLogDTO
     */
    void insertLog(@Param(value = "withdrawalLogDTO")WithdrawalLogDTO withdrawalLogDTO);

    /**
     * 新增系统日志
     * @param systemLog
     */
    void insertSystemLog(@Param(value = "systemLog")SystemLog systemLog);

    /**
     * 批量审核
     * @param ids
     * @param batch
     */
    void updateBatchByIds(List<String> ids, Integer batch);

    /**
     * 新增用户余额变动表记录
     * @param withRecordId
     * @param createUserId
     * @param adminUserType
     * @param financeDTO
     */
    void insertBalanceLog(String withRecordId, Long createUserId, int adminUserType, @Param(value = "financeDTO") FinanceDTO financeDTO);

    /**
     * 根据id修改联盟店审核的详情
     * @param businessDetailsDTO
     */
    void updateBusinessUserById(@Param(value = "businessDetailsDTO") BusinessDetailsDTO businessDetailsDTO);

    /**
     * 修改会员的主图
     * @param businessDetailsDTO
     */
    void updateBusinessUserByPhotoId(@Param(value = "businessDetailsDTO") BusinessDetailsDTO businessDetailsDTO);

    /**
     * 添加主图并返回id
     * @param businessPicDTO
     * @return
     */
    void insertPic(@Param(value = "businessPicDTO") BusinessPicDTO businessPicDTO);

    /**
     * 查询这个商家是否还有订单是未完成状态
     * @param id
     * @return
     */
    int selectOrderStatusById(Long id);

    /**
     * 打款新增用户余额变动表记录
     * @param balanceLog
     */
    void insertPaymentLog(@Param(value = "balanceLog") ShoppingBalanceLog balanceLog);

    /**
     * 积分充值账号
     * @param integral
     * @param userName
     * @return
     */
    void inUserName(@Param(value = "userName") String userName, @Param(value = "integral") Integer integral);

    /**
     * 积分支出账号
     * @param integral
     * @param id
     * @return
     */
    void outYlbh(@Param(value = "id") String id, @Param(value = "integral") Integer integral);

    /**
     * 查用户变动后的积分
     * @param userName
     * @return
     */
    GetUserInfoVO selectUserByUserName(@Param(value = "userName") String userName);

    /**
     * 增加积分转账记录
     * @param logEntity
     * @return
     */
    void insertRevenueLog(@Param(value = "logEntity") ShoppingUserRevenueLog logEntity);
}
